<template>
    <div>
        counter:{{ counter }}

    </div>
</template>

<script setup lang="ts" name='index'>
import { ref, reactive, onBeforeUnmount } from "vue";
import emitter from '@/utils/emitter';

let counter = ref(1);

emitter.on('send-mitt', (data) => {
    console.log("接受事件" + data);
    counter.value += (data as number)
})

//监控组件的销毁的动作
onBeforeUnmount(() => {
    emitter.off('send-mitt')
})


</script>

<style scoped></style>